<?PHP

ini_set("memory_limit","128M");
$post=$_POST;
$media = new media;
$media->post=$post;
$media->files=$_FILES;
$media->input['raw']='upload_image';
if($post['resize_image']==1 && !empty($post['resize_x']) && !empty($post['resize_y']))
{
	

	$media->input['resize_x']=$post['resize_x'];
	$media->input['resize_y']=$post['resize_y'];
	$media->resize_image=true;	
}


if($post['resize_thumb']==1 && !empty($post['resize_x_thumb']) && !empty($post['resize_y_thumb']))
{
	
	$media->input['resize_x_thumb']=$post['resize_x_thumb'];
	$media->input['resize_y_thumb']=$post['resize_y_thumb'];
	$media->resize_thumb=true;	
}
$media->gallery_image=TRUE;
$image_data=$media->process_image();
$z=0;
foreach($image_data as $x)
{
	
	$multipost[$z]=$post;

	$multipost[$z]['image']=$x['image'];
$multipost[$z]['thumb']=$x['thumb'];
$multipost[$z]['type']='image';
	process_sql_post($multipost[$z],$table,'add',NULL,NULL);
	printmessage('Successfully Added');
	$z++;
}
?>